package com.hjp.designmode.strategy.domain.impl;


import com.hjp.designmode.strategy.domain.Goods;

/**
 * @Description: 草莓
 * @Author: huangjp6
 * @Date: 2022/3/7 14:26
 */
public class Strawberry extends Goods {
    public Strawberry(StrawberryBuilder builder) {
        this.setOriginalPrice(builder.originalPrice);
        this.setCurrPrice(builder.currPrice);
        this.setWeight(builder.weight);
        this.setDiscount(builder.discount);
    }

    public Strawberry() {
        this(new StrawberryBuilder());
    }

    public static final class StrawberryBuilder {
        private double originalPrice;
        private double currPrice;
        private int weight;
        private double discount;

        public StrawberryBuilder() {
            originalPrice = 13.0;
            currPrice = 13.0;
            weight = 1;
            discount = 1.0;
        }

        StrawberryBuilder(Strawberry strawberry) {
            this.originalPrice = strawberry.getOriginalPrice();
            this.currPrice = strawberry.getCurrPrice();
            this.weight = strawberry.getWeight();
            this.discount = strawberry.getDiscount();
        }

        public StrawberryBuilder originalPrice(double val) {
            originalPrice = val;
            return this;
        }

        public StrawberryBuilder currPrice(double val) {
            currPrice = val;
            return this;
        }

        public StrawberryBuilder weight(int val) {
            weight = val;
            return this;
        }

        public StrawberryBuilder discount(double val) {
            discount = val;
            return this;
        }

        public Strawberry build() {
            return new Strawberry(this);
        }
    }
}
